/** * @license * Copyright (c) 2014, 2018, Oracle and/or its affiliates. * The Universal Permissive License (UPL), Version 1.0 */ "use strict";define(["ojs/ojcore","jquery","hammerjs","ojs/ojjquery-hammer","promise","ojs/ojcomponentcore","ojs/ojvalidation-base","ojs/ojpopup","ojs/ojlabel","ojs/ojanimation"],function(t,e,i){t.EditableValueUtils={},t.EditableValueUtils.validationContext={COMPONENT_CREATE:1,CONVERTER_OPTION_CHANGE:2,DISABLED_OPTION_CHANGE:3,READONLY_OPTION_CHANGE:4,REFRESH_METHOD:5,REQUIRED_OPTION_CHANGE:6,RESET_METHOD:7,USER_ACTION:8,VALIDATE_METHOD:9,VALIDATORS_OPTION_CHANGE:10,VALUE_OPTION_CHANGE:11},t.EditableValueUtils.validateMethodOptions={doValueChangeCheck:!1,validationContext:t.EditableValueUtils.validationContext.VALIDATE_METHOD},t.EditableValueUtils.converterOptionOptions={doNotClearMessages:!0,validationContext:t.EditableValueUtils.validationContext.CONVERTER_OPTION_CHANGE},t.EditableValueUtils.disabledOptionOptions={doNotClearMessages:!0,validationContext:t.EditableValueUtils.validationContext.DISABLED_OPTION_CHANGE},t.EditableValueUtils.requiredOptionOptions={doNotClearMessages:!0,validationContext:t.EditableValueUtils.validationContext.REQUIRED_OPTION_CHANGE},t.EditableValueUtils.readOnlyOptionOptions={doNotClearMessages:!0,validationContext:t.EditableValueUtils.validationContext.READONLY_OPTION_CHANGE},t.EditableValueUtils.refreshMethodOptions={doNotClearMessages:!0,validationContext:t.EditableValueUtils.validationContext.REFRESH_METHOD},t.EditableValueUtils.validatorsOptionOptions={doNotClearMessages:!0,validationContext:t.EditableValueUtils.validationContext.VALIDATORS_OPTION_CHANGE};t.EditableValueUtils.CUSTOM_LABEL_ELEMENT_ID="|label",t.EditableValueUtils.VALIDATE_VALUES={VALID:"valid",INVALID:"invalid"},t.EditableValueUtils.getAttributeValue=function(t,e){var i,s={};if(t&&e){var n=t[0];switch(e){case"disabled":i=n.hasAttribute("disabled")?!!n.disabled:void 0;break;case"pattern":i=n.pattern||void 0;break;case"placeholder":i=n.placeholder||void 0;break;case"readonly":i=n.hasAttribute("readonly")?!!n.readOnly:void 0;break;case"required":var a=n.required;i=n.hasAttribute("required")?void 0===a||!!a:void 0;break;case"title":i=n.hasAttribute("title")?n.title:void 0;break;case"value":i=t.val()||void 0;break;case"min":case"max":default:i=n.getAttribute(e)||void 0}}return void 0!==i?(s.fromDom=!0,s.value=i):s.fromDom=!1,s},t.EditableValueUtils.initializeOptionsFromDom=function(e,i,s,n){for(var a={},o=0;o0?e=this._ValidateReturnPromise():n?(i=function(){return a._ValidateReturnBoolean()?t.EditableValueUtils.VALIDATE_VALUES.VALID:t.EditableValueUtils.VALIDATE_VALUES.INVALID},e=Promise.resolve(i())):e=this._ValidateReturnBoolean(),e},t.EditableValueUtils._ValidateReturnPromise=function(){return this._SetValueReturnPromise(this._GetDisplayValue(),null,this._VALIDATE_METHOD_OPTIONS)},t.EditableValueUtils._ValidateReturnBoolean=function(){return this._SetValueReturnBoolean(this._GetDisplayValue(),null,this._VALIDATE_METHOD_OPTIONS)},t.EditableValueUtils.setSubIdForCustomLabelFor=function(t,e){t.setAttribute("id",e+"|input")},t.EditableValueUtils._updateLabelledBy=function(e,i,s){var n=t.EditableValueUtils.CUSTOM_LABEL_ELEMENT_ID;this._IsCustomElement()&&(e&&(e+=n),i&&(i+=n),e&&t.EditableValueUtils._removeAriaLabelledBy(s,e),i&&t.EditableValueUtils._addAriaLabelledBy(s,i))},t.EditableValueUtils._refreshRequired=function(t){var e,i,s,n=this._AriaRequiredUnsupported();this._refreshTheming("required",t),n||(i=this._GetContentElement(),(s=t)&&i?i[0].setAttribute("aria-required",s):i[0].removeAttribute("aria-required")),this._IsCustomElement()||(this.$label||this._createOjLabel(),this.$label&&(this.$label.ojLabel("option","showRequired",t),n&&(e=this._getAriaLabelledById(this.element))&&(t?this._addAriaDescribedBy(e+"_requiredIcon"):this._removeAriaDescribedBy(e+"_requiredIcon"))))},t.EditableValueUtils._AfterSetOptionRequired=function(e){this._refreshRequired(this._IsRequired()),this._runMixedValidationAfterSetOption(t.EditableValueUtils.requiredOptionOptions)},t.EditableValueUtils._AfterSetOptionValidators=function(){this._ResetAllValidators(),this._runFullValidationIfNeeded(t.EditableValueUtils.validatorsOptionOptions)},t.EditableValueUtils._AfterSetOptionAsyncValidators=function(){this._allAsyncValidators=null,this._updateValidatorMessagingHint(),this._runFullValidationIfNeeded(t.EditableValueUtils.validatorsOptionOptions)},t.EditableValueUtils._AfterSetOptionConverter=function(e){this._ResetConverter(),this._runFullValidationIfNeeded(t.EditableValueUtils.converterOptionOptions)||this._Refresh(e,this.options[e],!0)},t.EditableValueUtils._ResetConverter=function(){this._converter=null,this._getComponentMessaging().update(this._getMessagingContent(this._MESSAGING_CONTENT_UPDATE_TYPE.CONVERTER_HINT))},t.EditableValueUtils._GetNormalizedValidatorsFromOption=function(){var e,i,s,n,a,o,l=!0,r=[];if(s=this.options.validators)for(e=0;e=0&&(i=this.options.virtualKeyboard),null==i?this.element[0].removeAttribute("type"):this.element[0].setAttribute("type",i)};var s="invalidShown";t.__registerWidget("oj.editableValue",e.oj.baseComponent,{widgetEventPrefix:"oj",options:{describedBy:null,disabled:!1,displayOptions:{},help:void 0,helpHints:{definition:"",source:""},labelHint:"",messagesCustom:[],messagesHidden:void 0,messagesShown:void 0,title:"",valid:void 0,value:void 0,animateStart:null,animateEnd:null},getNodeBySubId:function(t){var e;if(!(e=this._super(t))&&!this._IsCustomElement()&&"oj-label-help-icon"===t.subId){var i=this._GetLabelElement();i&&(e=i.parent().find(".oj-label-help-icon"))}return e||null},getSubIdByNode:function(t){var i,s,n,a=null;return null!=t&&null!=(i=e(t).closest("a.oj-label-help-icon"))&&null!=(s=i.closest(".oj-label"))&&(n=s.find("label")[0])&&n==this._GetLabelElement()[0]&&(a={subId:"oj-label-help-icon"}),a},isValid:function(){return void 0===this._valid&&(this._valid=!this._hasInvalidMessages()),this._valid},refresh:function(){this._super(),this._doRefresh(!0)},reset:function(){this._clearAllMessages(),this._runDeferredValidation(this._VALIDATION_CONTEXT.RESET_METHOD),this._refreshComponentDisplayValue(this.options.value,!0)},showMessages:function(){var e,i,n,a=[],o=this.options.messagesHidden,l=o.length>0;for(e=0;e0?this._cloneMessagesBeforeSet(this.options.messagesCustom):[],this._SetDisabledDom(t),this._HasPlaceholderSet()&&(this._SetPlaceholder(this.options.placeholder),this._customPlaceholderSet=!0),e&&!this._IsCustomElement()){var i=t[0].tagName.toLowerCase();"input"!==i&&"textarea"!==i||["required","title","pattern"].forEach(function(i){i in e&&t.removeAttr(i)})}},_AfterCreate:function(){var t;this._super(),this._doRefresh(!1),this._IsCustomElement()?(void 0===this.customOjLabelElement&&(this.customOjLabelElement=this._getCustomOjLabelElement()),this.customOjLabelElement&&e(this.customOjLabelElement).addClass(this._GetDefaultStyleClass()+"-label"),this.customOjLabelElement&&this.customOjLabelElement.classList.add(this._GetDefaultStyleClass()+"-label")):this._createOjLabel(),(t=this.options.describedBy)&&this._addAriaDescribedBy(t),this._initComponentMessaging(),this._runDeferredValidation(this._VALIDATION_CONTEXT.COMPONENT_CREATE),this.options.messagesShown.length>0&&this._setMessagesOption("messagesShown",this.options.messagesShown,null,!0),this.widget()[0].classList.add("oj-form-control")},_SaveAttributes:function(t){this._IsCustomElement()||this._SaveAllAttributes(t)},_RestoreAttributes:function(t){this._IsCustomElement()||this._RestoreAllAttributes(t)},_AfterSetOption:function(e,i){switch(e){case"disabled":this._AfterSetOptionDisabledReadOnly(e,t.EditableValueUtils.disabledOptionOptions);break;case"displayOptions":if(this._IsCustomElement()){var s=this.options.displayOptions;if(null!=s){var n=s.helpInstruction;null!=n&&(s.title=n,this.options.displayOptions=s)}}this._initComponentMessaging();break;case"help":this._IsCustomElement()||this._Refresh(e,this.options[e]),this._IsCustomElement()&&(this.options.title=this.options.help.instruction,this._titleOptionChanged());break;case"messagesCustom":this._messagesCustomOptionChanged(i),this._setValidOption(this._determineValidFromMessagesOptions(),null);break;case"placeholder":this._placeholderOptionChanged(i);break;case"title":this._titleOptionChanged();break;case"translations":this.refresh();break;case"value":this._AfterSetOptionValue(e,i)}},_AfterSetOptionDisabledReadOnly:function(t,e){var i=!this.options[t];this._Refresh(t,this.options[t]),i&&this._runMixedValidationAfterSetOption(e)},_AfterSetOptionValue:function(t,e){var i,s=e?e._context:null,n=!1;s&&(n=!!s.originalEvent,i=s.doNotClearMessages||!1),n||(i||this._clearAllMessages(null),this._runDeferredValidation(this._VALIDATION_CONTEXT.VALUE_OPTION_CHANGE)),this._Refresh(t,this.options[t],!0)},_CanSetValue:function(){return!(this.options.disabled||!1)},_destroy:function(){var i,s,n=this._super();if(this._clearAllMessages(null,!0),this._getComponentMessaging().deactivate(),this.$label)for(s=this.$label.length,i=0;i0){for(e=0;e0&&(t=t.concat(n)),this._allValidators=t}return this._allValidators||[]},_ResetAllValidators:function(){this._allValidators&&(this._allValidators.length=0),this._allValidators=null,this._IsCustomElement()?this._updateValidatorMessagingHint():this._getComponentMessaging().update(this._getMessagingContent(this._MESSAGING_CONTENT_UPDATE_TYPE.VALIDATOR_HINTS))},_runFullValidationIfNeeded:function(t,e){var i,s=!1;return this._hasInvalidMessagesShowing()&&(s=!0),e&&this._clearComponentMessages(),s&&(e||this._clearComponentMessages(),i=this._getAllAsyncValidators(),this._IsCustomElement()&&0!==i.length?this._updateValueAsync(t):this._updateValueSyncOnly(t)),s},_getAllAsyncValidators:function(){return this._allAsyncValidators||(this._allAsyncValidators=this._GetNormalizedAsyncValidatorsFromOption()),this._allAsyncValidators},_getAllAsyncValidatorsWithHint:function(){var t,e,i,s=this._getAllAsyncValidators(),n=[];if(s.length>0)for(t=Object.prototype.hasOwnProperty,e=0;e0&&(e=s._getMessagingContent(s._MESSAGING_CONTENT_UPDATE_TYPE.VALIDATOR_HINTS),t=this._asyncValidatorHintCounter,this._setBusyStateAsyncValidatorHint(t),this._addAsyncValidatorsHintsMessagingContent(i,e).then(function(){s._clearBusyStateAsyncValidatorHint(t)}))},_updateValidatorMessagingHint:function(){var t,e=this._getAllAsyncValidatorsWithHint(),i=this._getComponentMessaging(),s=this,n=this._getMessagingContent(this._MESSAGING_CONTENT_UPDATE_TYPE.VALIDATOR_HINTS);e.length>0?(this._asyncValidatorHintCounter+=1,t=this._asyncValidatorHintCounter,this._setBusyStateAsyncValidatorHint(t),this._addAsyncValidatorsHintsMessagingContent(e,n).then(function(){s._clearBusyStateAsyncValidatorHint(t)})):i.update(n)},_addAsyncValidatorsHintsMessagingContent:function(t,e){var i,s=this._asyncValidatorHintCounter,n=this._getComponentMessaging(),a=[],o=this,l=[];for(i=0;it.Logger.LEVEL_WARN&&t.Logger.info((e.toString,e.toString()))}return!1},_SetValueReturnPromise:function(e,i,s){var n=!s||"boolean"!=typeof s.doValueChangeCheck||s.doValueChangeCheck,a=this;return new Promise(function(o){void 0===e&&(t.Logger.warn("Attempt to set a value of undefined"),o(t.EditableValueUtils.VALIDATE_VALUES.INVALID)),n&&e===a._getLastDisplayValue()?(t.Logger.level>t.Logger.LEVEL_WARN&&t.Logger.info((e.toString,e.toString())),o(t.EditableValueUtils.VALIDATE_VALUES.INVALID)):(a._setBusyState(e),a._AsyncValidate(e,i,s).then(function(n){var l;void 0!==n&&a.isValid()?(s&&s._context&&(l=s._context),a._updateValueOption(n,i,s&&s.validationContext,l),a._clearBusyState(e),o(t.EditableValueUtils.VALIDATE_VALUES.VALID)):(a._clearBusyState(e),o(t.EditableValueUtils.VALIDATE_VALUES.INVALID))}))})},_AsyncValidate:function(e,i,n){var a,o,l=n&&n.validationMode?n.validationMode:this._VALIDATION_MODE.FULL,r=n&&n.validationContext?n.validationContext:this._VALIDATION_CONTEXT.USER_ACTION,u=n&&n.doNotClearMessages||!1,g=this;return new Promise(function(n){if(void 0===e)t.Logger.warn("Attempt to set a value of undefined"),n(void 0);else if(g._CanSetValue()){u||g._clearAllMessages(i),g._setLastSubmittedValue(e);try{g._asyncValidatorValidateCounter+=1,o=l===g._VALIDATION_MODE.FULL?g._parseValue(e,i,!0):e,g._asyncValidateValue(o,i,r).then(function(t){n("valid"===t?o:void 0)})}catch(t){a=g._processValidationErrors(t,r),g._updateMessagesOption("messagesShown",a,i),g._setValidOption(s,i),n(void 0)}}else t.Logger.level>t.Logger.LEVEL_WARN&&(t.Logger.info("Validation skipped and value option not set as component state does not allow setting value. For example if the component is readonly or disabled."),n(void 0))})},_Validate:function(e,i,n){var a,o,l,r=n&&n.validationMode?n.validationMode:this._VALIDATION_MODE.FULL,u=n&&n.validationContext?n.validationContext:this._VALIDATION_CONTEXT.USER_ACTION,g=n&&n.doNotClearMessages||!1;if(void 0===e)t.Logger.warn("Attempt to set a value of undefined");else if(this._CanSetValue()){g||this._clearAllMessages(i),this._setLastSubmittedValue(e);try{return l=r===this._VALIDATION_MODE.FULL?this._parseValue(e,i,!0):e,(o=this._validateValue(l,i,u))&&this._setValidOption(this._determineValidFromMessagesOptions(),i),o?l:void 0}catch(t){a=this._processValidationErrors(t,u),this._updateMessagesOption("messagesShown",a,i),this._setValidOption(s,i)}}else t.Logger.level>t.Logger.LEVEL_WARN&&t.Logger.info("Validation skipped and value option not set as component state does not allow setting value. For example if the component is readonly or disabled.")},_CompareOptionValues:function(e,i,s){return"value"===e||"rawValue"===e?t.Object.compareValues(i,s):0===e.indexOf("messages")?this._messagesEquals(i,s):this._superApply(arguments)},_GetDefaultStyleClass:function(){return t.Assert.failedInAbstractFunction(),""},_MESSAGING_CONTENT_UPDATE_TYPE:{ALL:1,VALIDITY_STATE:2,CONVERTER_HINT:3,VALIDATOR_HINTS:4,TITLE:5},_OPTION_TO_CSS_MAPPING:{disabled:"oj-disabled",required:"oj-required"},_clearAllMessages:function(t,e){(e=!!e)?(this.options.messagesHidden=[],this.options.messagesShown=[],this.options.messagesCustom=[]):(this._clearMessages("messagesHidden",t),this._clearMessages("messagesShown",t),this._clearMessages("messagesCustom",t))},_clearComponentMessages:function(){var e,i=this.options.messagesShown;e=i.length,this._clearMessages("messagesHidden");for(var s=e-1;s>=0;s--)i[s]instanceof t.ComponentMessage&&i.splice(s,1);i.length!==e&&this._setMessagesOption("messagesShown",i,null,!0)},_setMessagesOption:function(t,e,i,s){var n={},a=0===e.length&&0===this.options[t].length;!s&&a||(n._context={originalEvent:i,writeback:!0,internalSet:!0},"messagesCustom"!==t&&(n._context.readOnly=!0),n.changed=s||!a,this._resetValid(),this.option(t,e,n),this._updateMessagingContent())},_setValidOption:function(t,e){var i={};"pending"===t&&"valid"!==this._determineValidFromMessagesOptions()||(i._context={originalEvent:e,writeback:!0,internalSet:!0,readOnly:!0},this.option("valid",t,i))},_clearMessages:function(t,e){this._setMessagesOption(t,[],e)},_cloneMessagesBeforeSet:function(e){var i,s,n,a=[];if(e&&e.length>0)for(i=0;i0},_hasInvalidComponentMessagesShowing:function(){for(var e,i,s=this.options.messagesShown,n=0;nt.Logger.LEVEL_WARN&&t.Logger.info("converter does not support the format method.")),i},_getComponentMessaging:function(){return this._componentMessaging||(this._componentMessaging=new t.ComponentMessaging(this)),this._componentMessaging},_getHintsForAllValidators:function(t){var e,i,s=[],n="";for(this._IsRequired()&&(i=this._getImplicitRequiredValidator()).getHint&&"function"==typeof i.getHint&&(n=i.getHint())&&s.push(n),e=0;e-1?r.splice(a,1):o=!1}),o)},_parseValue:function(e,i,s){var n=this._GetConverter(),a=e;if(n&&"object"==typeof n)if(n.parse&&"function"==typeof n.parse)try{s&&this._setValidOption("pending",i),a=n.parse(e)}catch(t){throw t}else t.Logger.level>t.Logger.LEVEL_WARN&&t.Logger.info("converter does not support the parse method.");return a},_addValidationError:function(e,i){var s,n,a,o;e instanceof t.ConverterError||e instanceof t.ValidatorError?(n=(a=e.getMessage()).severity||t.Message.SEVERITY_LEVEL.ERROR,o=a.summary||t.Translations.getTranslatedString("oj-message.error"),s=a.detail||t.Translations.getTranslatedString("oj-converter.detail")):e.summary||e.detail?(n=t.Message.SEVERITY_LEVEL.ERROR,o=e.summary||t.Translations.getTranslatedString("oj-message.error"),s=e.detail||t.Translations.getTranslatedString("oj-converter.detail")):(n=t.Message.SEVERITY_LEVEL.ERROR,o=t.Translations.getTranslatedString("oj-message.error"),s=e.message||t.Translations.getTranslatedString("oj-converter.detail")),i.push({summary:o,detail:s,severity:n})},_processValidationErrors:function(e,i,s){var n,a=[],o=e._messages||[],l={};l.context=i||0,l.display=s||t.ComponentMessage.DISPLAY.SHOWN,0===o.length&&this._addValidationError(e,o);for(var r=0;rt.Logger.LEVEL_WARN&&t.Logger.info("Deferred validation skipped as component is readonly or disabled."),this._setValidOption(this._determineValidFromMessagesOptions(),null)},_runMixedValidationAfterSetOption:function(t){!this._runFullValidationIfNeeded(t,!0)&&this._IsRequired()?this._runDeferredValidation(t.validationContext):this._setValidOption(this._determineValidFromMessagesOptions(),null)},_updateElementDisplayValue:function(t,e){var i,s,n;this._setLastModelValue(t),s=t;try{s=this._formatValue(t)}catch(t){n=this._processValidationErrors(t),this._updateMessagesOption("messagesShown",n,e)}this._SetDisplayValue(s),i=this._GetDisplayValue(),this._setLastSubmittedValue(i),this._SetRawValue(i,null)},_updateValueSyncOnly:function(t){var e=this._Validate(this._GetDisplayValue(),null,t);void 0===e||!this.isValid()&&this._hasInvalidComponentMessagesShowing()||this._updateValueOption(e,null,t.validationContext)},_updateValueAsync:function(t){var e=this,i=this._GetDisplayValue();e._setBusyState(i),this._AsyncValidate(i,null,t).then(function(s){void 0===s||!e.isValid()&&e._hasInvalidComponentMessagesShowing()||e._updateValueOption(s,null,t.validationContext),e._clearBusyState(i)})},_validateValueForRequiredOnly:function(e,i){var s,n;if(this._IsRequired()){n=this._getImplicitRequiredValidator();try{this._setValidOption("pending",null),n.validate(t.StringUtils.trim(e))}catch(e){(s=this._processValidationErrors(e,i,t.ComponentMessage.DISPLAY.HIDDEN))&&this._updateMessagesOption("messagesHidden",s)}}},_validateValue:function(e,i,n){var a,o,l,r,u=this._GetAllValidators(),g=this._IsRequired(),p=!1,d=[];if((g||u.length>0)&&this._setValidOption("pending",i),g){l=this._getImplicitRequiredValidator();try{l.validate(t.StringUtils.trim(e))}catch(t){this._addValidationError(t,d),this._setValidOption(s,i),p=!0}}for(a=0;at.Logger.LEVEL_WARN&&t.Logger.info("validator does not support the validate method.");return d.length>0&&((r=new Error)._messages=d,o=this._processValidationErrors(r,n),this._updateMessagesOption("messagesShown",o,i)),0===d.length},_asyncValidateValue:function(e,i,n){var a,o,l,r,u=this._getAllAsyncValidators(),g=!1,p=u.length>0,d=this,_=this._asyncValidatorValidateCounter;p&&this._setValidOption("pending",i),r=this._validateValue(e,i,n),p||r&&this._setValidOption(d._determineValidFromMessagesOptions(),i);var h=[];for(a=0;at.Logger.LEVEL_WARN&&t.Logger.info("Validate ignored because new value came in before async validator finished for "+e),s="ignore"),{v:i,status:s}},function(a){var o;return d._asyncValidatorValidateCounter===_?(l=d._processValidationErrors(a,n),d._updateMessagesOption("messagesShown",l,i),g||(d._setValidOption(s,i),g=!0),o="rejected"):(t.Logger.level>t.Logger.LEVEL_WARN&&t.Logger.info("Validate ignored because new value came in before async validator finished for "+e),o="ignore"),{e:a,status:o}})}return new Promise(function(t){Promise.all(h.map(c)).then(function(e){e.filter(function(t){return"ignore"===t.status}).length>0?o="ignoreValidation":(o=g?s:"valid",d._setValidOption(d._determineValidFromMessagesOptions(),i)),t(o)})})},_setBusyState:t.EditableValueUtils._SetBusyState,_clearBusyState:t.EditableValueUtils._ClearBusyState,_setBusyStateAsyncValidatorHint:t.EditableValueUtils._SetBusyStateAsyncValidatorHint,_clearBusyStateAsyncValidatorHint:t.EditableValueUtils._ClearBusyStateAsyncValidatorHint},!0),t.Components.setDefaultOptions({editableValue:{displayOptions:t.Components.createDynamicPropertyGetter(function(t){var e={messages:t.containers.indexOf("ojDataGrid")>=0||t.containers.indexOf("ojTable")>=0?["notewindow"]:["inline"],converterHint:["placeholder","notewindow"],validatorHint:["notewindow"]};return e[t.isCustomElement?"helpInstruction":"title"]=["notewindow"],e}),help:t.Components.createDynamicPropertyGetter(function(t){return t.isCustomElement?{instruction:""}:{definition:null,source:null}})}}),t.InlineMessagingStrategy=function(t){this.Init(t)},t.ComponentMessaging.registerMessagingStrategy(t.ComponentMessaging._DISPLAY_TYPE.INLINE,t.InlineMessagingStrategy),t.Object.createSubclass(t.InlineMessagingStrategy,t.MessagingStrategy,"oj.InlineMessagingStrategy"),t.InlineMessagingStrategy.prototype.reactivate=function(e){t.InlineMessagingStrategy.superclass.reactivate.call(this,e),this._updateInlineMessage()},t.InlineMessagingStrategy.prototype.shouldUpdate=function(t){return!(!t||void 0===t.validityState)},t.InlineMessagingStrategy.prototype.update=function(){t.InlineMessagingStrategy.superclass.update.call(this),this._updateInlineMessage()},t.InlineMessagingStrategy.prototype.deactivate=function(){this._removeMessagingContentRootDom(),t.InlineMessagingStrategy.superclass.deactivate.call(this)},t.InlineMessagingStrategy.prototype._getDefaultAnimation=function(){if(!t.InlineMessagingStrategy._defaultAnimation){var e=(t.ThemeUtils.parseJSONFromFontFamily("oj-messaging-inline-option-defaults")||{}).animation;e=e||{},t.InlineMessagingStrategy._defaultAnimation=e}return t.InlineMessagingStrategy._defaultAnimation},t.InlineMessagingStrategy.prototype._replaceAnimationOptions=function(e,i){var s,n;for(var a in t.StringUtils.isString(e)?(n=!0,s=e+""):(n=!1,s=JSON.stringify(e)),i)s=s.replace(new RegExp(a,"g"),i[a]);return e=n?s:JSON.parse(s)},t.InlineMessagingStrategy.prototype._determineAnimation=function(t,e){var i,s,n,a=this._getDefaultAnimation();if(a){var o,l=t[0],r=t[0].innerHTML,u=l.offsetHeight;t[0].innerHTML=e,o=l.offsetHeight,t[0].innerHTML=r,(s=a[i=o>u?"open":"close"])&&(n=this._replaceAnimationOptions(s,{"#oldHeight":u+"px","#newHeight":o+"px"}))}return{action:i,effect:n}},t.InlineMessagingStrategy.prototype._setBusyState=function(){if(!this._resolveBusyState){var e=this.GetComponent(),i=e?e.element:null,s=i?i[0]:null,n=t.Context.getContext(s).getBusyContext(),a="The page is waiting for inline message ";s&&s.id&&(a+='for "'+s.id+'" '),a+="to open/close",this._resolveBusyState=n.addBusyState({description:a})}},t.InlineMessagingStrategy.prototype._clearBusyState=function(){this._resolveBusyState&&(this._resolveBusyState(),this._resolveBusyState=null)},t.InlineMessagingStrategy.prototype._queueAction=function(e){var i=this,s=this.$messagingContentRoot;this._setBusyState(),this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=setTimeout(function(){if(i._timeoutId=null,s&&s[0]){var n=i._determineAnimation(s,e),a=n.action,o=n.effect;"close"===a?s[0].setAttribute("aria-live","off"):s[0].setAttribute("aria-live","polite"),"open"==a&&(s[0].innerHTML=e),t.AnimationUtils.startAnimation(s[0],"inline-"+a,o,i.GetComponent()).then(function(){"close"===a&&(s[0].setAttribute("aria-live","polite"),s[0].innerHTML=e),i._clearBusyState()})}else i._clearBusyState()},0)},t.InlineMessagingStrategy.prototype._updateInlineMessage=function(){var t;(t=this._buildInlineHtml())&&null==this.$messagingContentRoot&&this._createInlineMessage(),this.$messagingContentRoot&&this.$messagingContentRoot[0]&&(this.GetComponent()._IsCustomElement()?this._queueAction(t):t?this.$messagingContentRoot[0].innerHTML=t:this._removeMessagingContentRootDom())},t.InlineMessagingStrategy.prototype._createInlineMessage=function(){this.$messagingContentRoot=e(this._getInlineContentHtml()),this._addAriaDescribedBy(this.$messagingContentRoot),this._addAriaLive(this.$messagingContentRoot),this.GetComponent().widget()[0].appendChild(this.$messagingContentRoot[0])},t.InlineMessagingStrategy.prototype._getInlineContentHtml=function(){return"
"},t.InlineMessagingStrategy.prototype._removeMessagingContentRootDom=function(){if(null!=this.$messagingContentRoot){var t=this.$messagingContentRoot[0];this._removeAriaDescribedBy(this.$messagingContentRoot),t.parentNode.removeChild(t),this.$messagingContentRoot=null}},t.InlineMessagingStrategy.prototype._addAriaDescribedBy=function(i){var s,n,a,o,l=(n=this.GetLauncher())[0];t.Assert.assertPrototype(n,e),t.Assert.assertPrototype(i,e),a=i.uniqueId()[0].getAttribute("id"),(o=(s=l.getAttribute("aria-describedby"))?s.split(/\s+/):[]).push(a),null==(s=o.join(" ").trim())?l.removeAttribute("aria-describedby"):l.setAttribute("aria-describedby",s)},t.InlineMessagingStrategy.prototype._addAriaLive=function(i){t.Assert.assertPrototype(i,e),i[0].setAttribute("aria-live","polite")},t.InlineMessagingStrategy.prototype._removeAriaDescribedBy=function(i){var s,n,a,o,l;a=this.GetLauncher(),t.Assert.assertPrototype(a,e),t.Assert.assertPrototype(i,e),o=i[0].getAttribute("id"),-1!==(n=(l=(s=a[0].getAttribute("aria-describedby"))?s.split(/\s+/):[]).indexOf(o))&&l.splice(n,1),(s=l.join(" ").trim())?a[0].setAttribute("aria-describedby",s):a[0].removeAttribute("aria-describedby")},t.InlineMessagingStrategy.prototype._buildInlineHtml=function(){var t;return this.ShowMessages()?(t=this.GetComponent().document[0],this._buildMessagesHtml(t)):""},t.InlineMessagingStrategy.prototype._buildMessagesHtml=function(e){var i,s,n="";return this.HasMessages()&&(s=this.GetMessages(),i=this.GetMaxSeverity(),n=t.PopupMessagingStrategyUtils.buildMessagesHtml(e,s,i,!0)),n},t.PopupMessagingStrategy=function(t){this.Init(t)},t.ComponentMessaging.registerMessagingStrategy(t.ComponentMessaging._DISPLAY_TYPE.NOTEWINDOW,t.PopupMessagingStrategy),t.Object.createSubclass(t.PopupMessagingStrategy,t.MessagingStrategy,"oj.PopupMessagingStrategy"),t.PopupMessagingStrategy._DEFAULTS_BY_COMPONENT={ojRadioset:{position:"launcher",events:{open:"focusin mouseenter press",close:"mouseleave"}},ojCheckboxset:{position:"launcher",events:{open:"focusin mouseenter press",close:"mouseleave"}},ojInputText:{position:"launcher",events:{open:"focusin"}},ojTextArea:{position:"launcher",events:{open:"focusin"}},ojInputPassword:{position:"launcher",events:{open:"focusin"}},ojSwitch:{position:"launcher",events:{open:"focusin mouseenter",close:"mouseleave"}},ojSlider:{position:"launcher",events:{open:"focusin mouseenter",close:"mouseleave"}},ojColorSpectrum:{position:"launcher",events:{open:"focusin mouseenter",close:"mouseleave"}},ojColorPalette:{position:"launcher",events:{open:"focusin mouseenter",close:"mouseleave"}},default:{position:"launcher-wrapper",events:{open:"focusin"}}},t.PopupMessagingStrategy._SELECTOR_FORMCONTROL_HINT="oj-form-control-hint",t.PopupMessagingStrategy._SELECTOR_FORMCONTROL_HINT_CONVERTER="oj-form-control-hint-converter",t.PopupMessagingStrategy._SELECTOR_FORMCONTROL_HINT_VALIDATOR="oj-form-control-hint-validator",t.PopupMessagingStrategy._SELECTOR_FORMCONTROL_HINT_TITLE="oj-form-control-hint-title",t.PopupMessagingStrategy._OPEN_NAMESPACE=".ojPopupMessagingOpen",t.PopupMessagingStrategy._CLOSE_NAMESPACE=".ojPopupMessagingClose",t.PopupMessagingStrategy.prototype.activate=function(e){t.PopupMessagingStrategy.superclass.activate.call(this,e),this._initMessagingPopup()},t.PopupMessagingStrategy.prototype.reactivate=function(e){t.PopupMessagingStrategy.superclass.reactivate.call(this,e),this._updatePopupIfOpen()},t.PopupMessagingStrategy.prototype.update=function(){t.PopupMessagingStrategy.superclass.update.call(this),this._updatePopupIfOpen()},t.PopupMessagingStrategy.prototype.deactivate=function(){this._unregisterLauncherEvents(),this._destroyTooltip(),t.PopupMessagingStrategy.superclass.deactivate.call(this)},t.PopupMessagingStrategy.prototype.close=function(){this._closePopup()},t.PopupMessagingStrategy.prototype._closePopup=function(){this._queueAction(function(t){if(this._isPopupInitialized())return t&&this._setActionResolver(this.$messagingContentRoot,"close",t),void this.$messagingContentRoot.ojPopup("close");t&&t(!0)}.bind(this))},t.PopupMessagingStrategy.prototype._initMessagingPopup=function(){this._openPopupCallback||this._registerLauncherEvents()},t.PopupMessagingStrategy.prototype._addAnimateEventListeners=function(t){var e=function(t,e,i){var s=this.GetComponent();s&&s._trigger&&(e.stopPropagation(),s._trigger(t,null,i)||e.preventDefault())};t.on("ojanimatestart.notewindow",e.bind(this,"animateStart")),t.on("ojanimateend.notewindow",e.bind(this,"animateEnd"))},t.PopupMessagingStrategy.prototype._removeAnimateEventListeners=function(t){t.off("ojanimatestart.notewindow"),t.off("ojanimateend.notewindow")},t.PopupMessagingStrategy.prototype._setBusyState=function(e){var i=this.GetComponent(),s=i?i.element:null,n=s?s[0]:null,a=t.Context.getContext(n).getBusyContext(),o="The page is waiting for note window ";return n&&n.id&&(o+='for "'+n.id+'" '),o+="to "+e,a.addBusyState({description:o})},t.PopupMessagingStrategy.prototype._setActionResolver=function(t,e,i){var s;this._actionCount>1&&(s=t.ojPopup("option","animation"),t.ojPopup("option","animation",null));var n=this._setBusyState(e);t.one("oj"+e,function(){s&&t.ojPopup("option","animation",s),n(),i(!0)})},t.PopupMessagingStrategy.prototype._queueAction=function(t){if(this.GetComponent()._IsCustomElement()){var e=this,i=function(t){var i=new Promise(t);return i.then(function(){--e._actionCount}),i};this._actionCount?(++this._actionCount,this._actionPromise=this._actionPromise.then(function(){return i(t)})):(this._actionCount=1,this._actionPromise=i(t))}else t(null)},t.PopupMessagingStrategy.prototype._openPopup=function(e){this._queueAction(function(i){var s,n,a;if(this._canOpenPopup()&&(n=this._buildPopupHtml(),!t.StringUtils.isEmptyOrUndefined(n))){var o=this._getPopupElement(),l=o.ojPopup("isOpen");if((s=t.PopupMessagingStrategyPoolUtils.getPopupContentNode(o)).innerHTML="",s.innerHTML=n,!l)return a=this.GetLauncher(),"press"===e.type&&this._openPopupOnPressEvent(a),i&&this._setActionResolver(o,"open",i),void o.ojPopup("open",a);l&&o.ojPopup("refresh")}i&&i(!0)}.bind(this))},t.PopupMessagingStrategy.prototype._openPopupOnPressEvent=function(t){this._inPressEvent=!0,t[0].addEventListener("click",this._eatChangeAndClickOnPress,!0),t[0].addEventListener("change",this._eatChangeAndClickOnPress,!0),t.one("touchend",function(t){setTimeout(function(){this._inPressEvent=!1},50)})},t.PopupMessagingStrategy.prototype._eatChangeAndClickOnPress=function(t){this._inPressEvent&&(t.preventDefault(),t.stopPropagation(),"click"===t.type&&(this._inPressEvent=!1))},t.PopupMessagingStrategy.prototype._canOpenPopup=function(){var t=this.GetComponent().options,e=t.disabled||!1,i=t.readOnly||!1;return!(e||i)},t.PopupMessagingStrategy.prototype._updatePopupIfOpen=function(){var e,i,s,n,a=!1;if(this._isPopupInitialized()){if(a=(n=this._getPopupElement()).ojPopup("isOpen"),e=this._buildPopupHtml(),null==this.GetLauncher())return;s=document.activeElement===this.GetLauncher()[0],a?e?((i=t.PopupMessagingStrategyPoolUtils.getPopupContentNode(n)).innerHTML="",i.innerHTML=e,n.ojPopup("refresh")):n.ojPopup("close"):s&&e&&this._openPopup(void 0)}},t.PopupMessagingStrategy.prototype._unregisterLauncherEvents=function(){var e,i=this.GetLauncher();(e=t.PopupMessagingStrategy._DEFAULTS_BY_COMPONENT[this.GetComponent().widgetName])?e.events:t.PopupMessagingStrategy._DEFAULTS_BY_COMPONENT.default.events,i.off(t.PopupMessagingStrategy._OPEN_NAMESPACE),i.off(t.PopupMessagingStrategy._CLOSE_NAMESPACE),i[0].removeEventListener("click",this._eatChangeAndClickOnPress,!0),i[0].removeEventListener("change",this._eatChangeAndClickOnPress,!0),t.DomUtils.isTouchSupported()&&(i.ojHammer().off("press"),i.ojHammer("destroy"),i.off("contextmenu",this._eatContextMenuOnOpenPopupListener),this._eatContextMenuOnOpenPopupListener=null,this._inPressEvent=null),this._openPopupCallback=null,this._closePopupCallback=null},t.PopupMessagingStrategy.prototype._registerLauncherEvents=function(){var e,s,n,a,o,l,r,u,g=this.GetLauncher();(a=(n=t.PopupMessagingStrategy._DEFAULTS_BY_COMPONENT[this.GetComponent().widgetName])?n.events:t.PopupMessagingStrategy._DEFAULTS_BY_COMPONENT.default.events).open&&((r=this._openPopupCallback)||(r=this._openPopupCallback=this._openPopup.bind(this)),u=a.open.indexOf("press"),l=this._getNamespacedEvents(a.open.replace("press",""),t.PopupMessagingStrategy._OPEN_NAMESPACE),g.on(l,r),t.DomUtils.isTouchSupported()&&(this._eatContextMenuOnOpenPopupListener=function(t){return!1},g.on("contextmenu",this._eatContextMenuOnOpenPopupListener),-1!==u&&(o={recognizers:[[i.Press,{time:750}]]},g.ojHammer(o).on("press",r)))),a.close&&((s=this._closePopupCallback)||(s=this._closePopupCallback=this._closePopup.bind(this)),e=this._getNamespacedEvents(a.close,t.PopupMessagingStrategy._CLOSE_NAMESPACE),g.on(e,s))},t.PopupMessagingStrategy.prototype._getNamespacedEvents=function(t,e){var i,s,n;if(""===t||""===e)return t;n=(i=t.split(" ")).length,s=[];for(var a=0;a"+a+"":""},t.PopupMessagingStrategy.prototype._isPopupInitialized=function(){return!!this.$messagingContentRoot&&t.Components.isComponentInitialized(this.$messagingContentRoot,"ojPopup")},t.PopupMessagingStrategyUtils={},t.PopupMessagingStrategyUtils.buildHintHtml=function(e,i,s,n,a){var o;if(s){o=e.createElement("div");for(var l=a.split(" "),r=0,u=l.length;r=t.Message.SEVERITY_LEVEL.CONFIRMATION;o--)for(h=c[o]||[],l=0;l0){var i=(e=t.PopupMessagingStrategyPoolUtils.getNextFreePopup())[0];e.ojPopup("destroy"),i.parentNode.removeChild(i)}},t.PopupMessagingStrategyPoolUtils._getPool=function(){var i=e("#"+t.PopupMessagingStrategyPoolUtils._MESSAGING_POPUP_POOL_ID);if(i.length>0)return i;var s=(i=e("
"))[0];return s.setAttribute("id",t.PopupMessagingStrategyPoolUtils._MESSAGING_POPUP_POOL_ID),s.setAttribute("role","presentation"),document.body.appendChild(s),i},t.PopupMessagingStrategyPoolUtils._getFreePoolCount=function(){return t.PopupMessagingStrategyPoolUtils._getPool().find("."+t.PopupMessagingStrategyPoolUtils._SELECTOR_MESSAGING).length},t.PopupMessagingStrategyPoolUtils._getPopupContentHtml=function(){return'
'},t.PopupMessagingStrategyPoolUtils._SELECTOR_MESSAGING_CONTAINER="oj-messaging-popup-container",t.PopupMessagingStrategyPoolUtils._SELECTOR_MESSAGING="oj-messaging-popup",t.PopupMessagingStrategyPoolUtils._MESSAGING_POPUP_POOL_ID="__oj_messaging_popup_pool",t.CustomElementBridge.registerMetadata("editableValue","baseComponent",{extension:{_WIDGET_NAME:"editableValue"}})});